package com.example.mghotel.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.mghotel.R;

public class LoginActivity extends AppCompatActivity {

    //kongjian
    private Button btnSubmit;
    private LinearLayout llSms;
    private LinearLayout llPassword;
    private TextView tvSms;
    private TextView tvPassword;
    private TextView tvRegister;
    private TextView tvForgetPassword;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //设置布局
        setContentView(R.layout.activity_login);

        //获取控件
        btnSubmit = findViewById(R.id.btn_login_submit);
        llSms = findViewById(R.id.ll_login_sms);
        llPassword = findViewById(R.id.ll_login_password);
        tvSms = findViewById(R.id.tv_login_sms);
        tvPassword = findViewById(R.id.tv_login_password);
        tvRegister = findViewById(R.id.tv_login_register);
        tvForgetPassword = findViewById(R.id.tv_login_foget_password);

        //设置控件事件
        setViewListener();

        //匿名内部类
        btnSubmit.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                Toast.makeText(LoginActivity.this,"登录成功",Toast.LENGTH_LONG).show();
            }
        });
    }


    //设置控件事件
    private void setViewListener() {

        //注册新用户 点击事件
        tvRegister.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(LoginActivity.this,RegisterActivity.class);
                startActivity(intent);
            }
        });

        //重置密码 点击事件
        tvForgetPassword.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(LoginActivity.this,ForgetPasswordActivity.class);
                startActivity(intent);
            }
        });



        //密码登录
        tvPassword.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                llPassword.setVisibility(View.VISIBLE);
                tvSms.setVisibility((View.VISIBLE));
                llSms.setVisibility(View.GONE);
                tvPassword.setVisibility(View.GONE);
            }
        });

        //验证码登录
        tvSms.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                llPassword.setVisibility(View.GONE);
                tvSms.setVisibility((View.GONE));
                llSms.setVisibility(View.VISIBLE);
                tvPassword.setVisibility(View.VISIBLE);
            }
        });
    }
}
